<template>
    <div id="background">
        <el-container>
            <el-header id="editHeadPosition">
                 <el-row type="flex" style="height:77%;display:flex;align-items: flex-end;">
                    <el-col :xs="2" :sm="2" :md="2" :offset="1" class="imgCol">
                        <img v-bind:src="backIcon" class="backSize" @click="back"/>
                    </el-col>
                    <el-col :xs="6" :sm="6" :md="6" :offset="6" class="imgCol"> 
                        <span class="titleSize">编辑资料</span>
                    </el-col>
                </el-row>
            </el-header>
            <el-main id="editMainPositon">
                <span @click="goToEditPhoto">
                 <el-row id="Photo" type="flex" class="infoHeight" >
                       <el-col :xs="3" :sm="3" :md="3" :offset="2" class="imgCol">
                            <span class="infoWords">头像</span>
                        </el-col>
                        <el-col :xs="9" :sm="9" :md="9" :offset="4" class="imgCol">
                        </el-col>
                        <el-col :xs="5" :sm="5" :md="5" class="imgCol">
                           <!-- <el-avatar :size="40" :src="info.head"  class="imgCol"></el-avatar>-->
                            <el-avatar :size="40" :src="info.head"  class="imgCol">
                                <img src="https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png" />
                            </el-avatar>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
                <span  @click="goToEditName">
                    <el-row  type="flex" class="infoHeight" >
                        <el-col :xs="3" :sm="3" :md="3" :offset="2" class="imgCol">
                            <span class="infoWords">昵称</span>
                        </el-col>
                        <el-col :xs="9" :sm="9" :md="9" :offset="6"  class="imgColReverse">
                            <span class="infoWords">{{info.nickname}}</span>
                        </el-col>
                        <el-col :xs="3" :sm="3" :md="3"  class="imgCol">
                            <span class="infoWords">></span>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
                <span  @click="goToEditGender">
                    <el-row type="flex" class="infoHeight" >
                         <el-col :xs="3" :sm="3" :md="3" :offset="2"  class="imgCol">
                            <span class="infoWords">性别</span>
                        </el-col>
                        <el-col :xs="9" :sm="9" :md="9" :offset="6"  class="imgColReverse">
                            <span class="infoWords">{{gender}}</span>
                        </el-col>
                         <el-col :xs="3" :sm="3" :md="3"  class="imgCol">
                            <span class="infoWords">></span>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
                <span  @click="goToEditArea">
                    <el-row type="flex" class="infoHeight" >
                        <el-col :xs="3" :sm="3" :md="3" :offset="2" class="imgCol">
                            <span class="infoWords">地区</span>
                        </el-col>
                        <el-col :xs="12" :sm="12" :md="12" :offset="3"  class="imgColReverse">
                            <span class="infoWords">{{info.province}} {{info.city}} {{info.area}}</span>
                        </el-col>
                         <el-col :xs="3" :sm="3" :md="3"  class="imgCol">
                            <span class="infoWords">></span>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
                <span @click="goToEditYear">
                    <el-row type="flex" class="infoHeight" >
                        <el-col :xs="3" :sm="3" :md="3" :offset="2" class="imgCol">
                            <span class="infoWords">生日</span>
                        </el-col>
                        <el-col :xs="9" :sm="9" :md="9" :offset="6"  class="imgColReverse">
                            <span class="infoWords">{{info.birthday}}</span>
                        </el-col>
                         <el-col :xs="3" :sm="3" :md="3"  class="imgCol">
                            <span class="infoWords">></span>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
                <span @click="goToEditZhiYe">
                    <el-row  type="flex" class="infoHeight" >
                        <el-col :xs="3" :sm="3" :md="3" :offset="2" class="imgCol">
                            <span class="infoWords">职业</span>
                        </el-col>
                        <el-col :xs="9" :sm="9" :md="9" :offset="6"  class="imgColReverse">
                            <span class="infoWords">{{info.occupation}}</span>
                        </el-col>
                         <el-col :xs="3" :sm="3" :md="3"  class="imgCol">
                            <span class="infoWords">></span>
                        </el-col>
                </el-row>
                </span>
                <el-row>
                    <el-col class="imgCol">
                        <div class="line"></div>
                    </el-col>
                </el-row>
            </el-main>
        </el-container>
    </div>
</template>
<script>
import backIcon from '../../assets/img/mine/geRenZhongXin/back.png'
import userPhoto from '../../assets/img/mine/geRenZhuYe/test.jpg'
export default {
    data(){
        return{
            backIcon:backIcon,
            userPhoto:userPhoto,
            normalHeight:document.documentElement.clientHeight,
            gender:'女',
            info:{
                username:'',
                realname:'',
                nickname:'',
                occupation:'',
                hasQualification:false,
                birthday:'',
                province:'',
                city:'',
                area:'',
                head:'',
            }
        }
    },
    mounted(){
        var normalHeight=sessionStorage.getItem('normalHeight');
        var bg = document.getElementById("background");
       // normalHeight=document.documentElement.clientHeight;
        console.log("height:"+normalHeight);
        bg.style.height = normalHeight+"px";
        bg.style.backgroundColor = "#FFFFFF"
        bg.style.margin = "0px";
        
        var head=document.getElementById("editHeadPosition");
        var headHeight=normalHeight/30 *4 ;
        console.log("headHeight:"+headHeight);
        head.style.height=headHeight+"px";

         var main=document.getElementById("editMainPositon");
        var mainHeight=normalHeight/30 *26;
        console.log("mainHeight:"+mainHeight);
        main.style.height=mainHeight+"px";

        this.getGeRenZhuYe();

    },
    methods:{
        back(){
            console.log("back:");
            this.$router.go(-1);
        },
        goToEditPhoto(){
            this.$router.push({
                path:'/edit/photo',
                query:{
                    head:this.info.head
                }
            })
        },
        goToEditName(){
            console.log(this.info);
            this.$router.push({
                path:'/edit/name',
                query:{
                    nickname:this.info.nickname
                }
            })
        },
        goToEditGender(){
            this.$router.push({
                path:'/edit/gender',
                query:{
                    sex:this.info.sex
                }
            })
        },
        goToEditArea(){
             this.$router.push({
                path:'/edit/area',
                query:{
                    province:this.info.province,
                    city:this.info.city,
                    area:this.info.area
                }
            })
        },
        goToEditYear(){
             this.$router.push({
                path:'/edit/year',
                query:{
                    birthday:this.info.birthday
                }
            })
        },
        goToEditZhiYe(){
             this.$router.push({
                path:'/edit/zhiYe',
                query:{
                    occupation:this.info.occupation
                }
            })
        },
        //获取个人主页信息
        getGeRenZhuYe(){
            var URL=this.IP.IP+'/user/mainInfo';
            console.log(URL);
            this.$ajax({
                method:'get',
                url:URL,
            }).then(response=>{
                console.log(response.data);
                var code=response.data.code;
                if(code==0){
                    this.info=response.data.data;
                    if(this.info.sex==false){
                        this.gender='女';
                    }else{
                        this.gender='男';
                    }
                }else{
                    Toast(response.data.ms);
                }
            }).catch(error=>{
                console.log(error);
                //Toast(error);
            })
        }
    }
}
</script>

<style>
.el-row--flex{
    padding: 0px;
    margin: 0px;
}
.van-field__control {
    color: #707070;
}
#editHeadPosition{
    background-color: #53cdf5;
}
.imgCol{
    display:flex;
    align-items:center;
    justify-content:center
}
.imgColReverse{
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.line{
    width: 90%;
    height: 1px;
    background-color: #F0F0F0;
}
.infoWords{
    color: #707070;
}
.infoHeight{
    height:10%;
    /* height: 55px; */

}
.linePosition{
    display: flex;
    align-items: flex-end;
}
.el-main {
    padding: 0px ;
}
.backSize{
    height: 26px;
}
.titleSize{
    font-size:1.125em;
    color:#ffffff
}
@media screen and (max-height: 600px){
  .backSize{
      height: 22px;
  }
  .titleSize{
      font-size: 1em;
  }
}
</style>
